using System;

namespace Sponsorship.ReadModel
{
    /// <summary>
    /// Acts as a base class for data transfer objects exposed by the read-model of the application.
    /// </summary>
    public abstract class Dto
    {
        public string Id
        {
            get { return GetDtoIdOf(AggregateRootId, GetType()); }
        }

        public Guid AggregateRootId { get; set; }

        public int Version { get; set; }

        public static string GetDtoIdOf<T>(Guid id) where T : Dto
        {
            return GetDtoIdOf(id, typeof(T));
        }

        public static string GetDtoIdOf(Guid id, Type type)
        {
            return type.Name + "/" + id;
        }
    }
}